package com.sbtr.controller.classify;

import com.sbtr.common.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.sbtr.common.PageDto;
import com.sbtr.business.classify.entity.AlgoTemplateParam;
import com.sbtr.business.classify.dto.AlgoTemplateParamDto;
import com.sbtr.business.classify.service.AlgoTemplateParamService;
import org.springframework.web.bind.annotation.RestController;
import com.sbtr.controller.common.CommonController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 轻量化算法模板参数(高质量芯片项目)，属于参数版本子表 前端控制器
 *
 * @author maojianping
 * @since 2023-04-17
 */
@RestController
@RequestMapping("/algoTemplateParam")
@ApiIgnore
public class AlgoTemplateParamController extends CommonController<AlgoTemplateParam,AlgoTemplateParamService> {

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "分页列表")
    public Response<PageDto<AlgoTemplateParam>> pageList(AlgoTemplateParamDto algoTemplateParamDto){
        return Response.success(u.pageList(algoTemplateParamDto));
    }

    @PostMapping("/addByOwner")
    @ApiOperation(httpMethod = "POST", value = "新增算法参数（必须算法文件所属者操作，一般是未从文件正确读取到，需要上传）")
    public Response<AlgoTemplateParam> addByOwner(@RequestBody AlgoTemplateParam algoTemplateParam){
        algoTemplateParam.setId(null);
        if(algoTemplateParam.insert()){
            return Response.success(algoTemplateParam);
        }else throw new BDException("算法参数新增失败");
    }

}

